using System;
using EnvDTE;
using EnvDTE80;

namespace Specialwork.AddIns.VisualStudio
{
    /// <summary>
    /// Bietet spezielle statische Methoden zur Steuerung des Eigenschaftsfensters.
    /// </summary>
    public static class PropertyWindow
    {
        /// <summary>
        /// Setzt das aktuelle Objekt im Eigenschaftsfenster
        /// </summary>
        /// <param name="application"></param>
        /// <param name="currentToolWindow"></param>
        /// <param name="selectedObject"></param>
        /// <param name="activateWindow"></param>
        public static void SetPropertyEditorObject(DTE2 application, Window2 currentToolWindow, object selectedObject, bool activateWindow)
        {
            if (application == null) throw new ArgumentNullException();
            if (currentToolWindow == null) throw new ArgumentNullException();
            if (selectedObject == null) throw new ArgumentNullException();

            object[] selectedObjects = new object[] { selectedObject };

            currentToolWindow.SetSelectionContainer(ref selectedObjects);

            if (activateWindow)
            {
                Windows.ActivateStaticWindow(application, Constants.vsWindowKindProperties);
            }
        }
    }
}